# Methods added to this helper will be available to all templates in the application.
module ApplicationHelper
  #format comment's content that make '\n' to a paragraph.
  def simple_format(text)
    content_tag 'p', text.to_s.
      gsub(/\r\n?/, "\n").               # \r\n and \r -> \n
      gsub(/\n+/, "</p>\n<p>").
      gsub(/([^\n]\n)(?=[^\n])/, '\1')   # 1 newline   -> br
  end  
end
